package com.fulihui.weixinclient.request;

import com.alibaba.fastjson.JSON;
import com.fulihui.weixinclient.http.HttpMethodEnum;
import com.fulihui.weixinclient.result.RefreshTokenResult;

/**
 * @author: Levon
 * @version: v 0.1 2017-08-18 16:41
 */
public class RefreshTokenRequest extends WeixinJsonRequest<RefreshTokenResult>{

    private String appid;

    /* refresh_token */
    private String grant_type       = "refresh_token";

    private String refresh_token;

    @Override
    protected void childParam() {
        addParam("appid", appid);
        addParam("grant_type", grant_type);
        addParam("refresh_token", refresh_token);
    }

    @Override
    public String service() {
        return "https://api.weixin.qq.com/sns/oauth2/refresh_token";
    }

    @Override
    public String urlEndStr() {
        return null;
    }

    @Override
    public RefreshTokenResult parseResult(String respStr) {
        RefreshTokenResult result = JSON.parseObject(respStr,RefreshTokenResult.class);
        checkResult(result);
        return result;
    }

    @Override
    public HttpMethodEnum httpMethod() {
        return HttpMethodEnum.SSL_GET;
    }

    @Override
    public String requestData() {
        return null;
    }
    @Override
    public void setAppid(String appid) {
        this.appid = appid;
    }

    public void setGrant_type(String grant_type) {
        this.grant_type = grant_type;
    }

    public void setRefresh_token(String refresh_token) {
        this.refresh_token = refresh_token;
    }
}
